#ifndef CPP_KEYEVENT_H
#define CPP_KEYEVENT_H

//@brief 按键事件
//@author cvte
class KeyEvent {
   public:
    const static int ACTION_UP = 0;
    const static int ACTION_DOWN = 1;
    const static int KEYCODE_ESCAPE                 = 1;

    const static int KEYCODE_1                      = 2;
    const static int KEYCODE_2                      = 3;
    const static int KEYCODE_3                      = 4;
    const static int KEYCODE_4                      = 5;
    const static int KEYCODE_5                      = 6;
    const static int KEYCODE_6                      = 7;
    const static int KEYCODE_7                      = 8;
    const static int KEYCODE_8                      = 9;
    const static int KEYCODE_9                      = 10;
    const static int KEYCODE_0                      = 11;

    const static int KEYCODE_MINUS                  = 12;
    const static int KEYCODE_EQUAL                  = 13;

    const static int KEYCODE_BACKSPACE              = 14;
    const static int KEYCODE_TAB                    = 15;

    const static int KEYCODE_Q                      = 16;
    const static int KEYCODE_W                      = 17;
    const static int KEYCODE_E                      = 18;
    const static int KEYCODE_R                      = 19;
    const static int KEYCODE_T                      = 20;
    const static int KEYCODE_Y                      = 21;
    const static int KEYCODE_U                      = 22;
    const static int KEYCODE_I                      = 23;
    const static int KEYCODE_O                      = 24;
    const static int KEYCODE_P                      = 25;
    const static int KEYCODE_BRACKET_LEFT           = 26;
    const static int KEYCODE_BRACKET_RIGHT          = 27;

    const static int KEYCODE_ENTER                  = 28;

    const static int KEYCODE_LEFTCONTROL            = 29;

    const static int KEYCODE_A                      = 30;
    const static int KEYCODE_S                      = 31;
    const static int KEYCODE_D                      = 32;
    const static int KEYCODE_F                      = 33;
    const static int KEYCODE_G                      = 34;
    const static int KEYCODE_H                      = 35;
    const static int KEYCODE_J                      = 36;
    const static int KEYCODE_K                      = 37;
    const static int KEYCODE_L                      = 38;
    const static int KEYCODE_SEMICOLON              = 39;
    const static int KEYCODE_APOSTROPHE             = 40;
    const static int KEYCODE_GRAVE                  = 41;

    const static int KEYCODE_LEFTSHIFT              = 42;
    const static int KEYCODE_BACKSLASH              = 43;

    const static int KEYCODE_Z                      = 44;
    const static int KEYCODE_X                      = 45;
    const static int KEYCODE_C                      = 46;
    const static int KEYCODE_V                      = 47;
    const static int KEYCODE_B                      = 48;
    const static int KEYCODE_N                      = 49;
    const static int KEYCODE_M                      = 50;
    const static int KEYCODE_COMMA                  = 51;
    const static int KEYCODE_PERIOD                 = 52;
    const static int KEYCODE_SLASH                  = 53;

    const static int KEYCODE_RIGHTSHIFT             = 54;
    const static int KEYCODE_KEYPADMULTIPLY         = 55;

    const static int KEYCODE_LEFTALT                = 56;
    const static int KEYCODE_SPACE                  = 57;
    const static int KEYCODE_CAPSLOCK               = 58;

    const static int KEYCODE_F1                     = 59;
    const static int KEYCODE_F2                     = 60;
    const static int KEYCODE_F3                     = 61;
    const static int KEYCODE_F4                     = 62;
    const static int KEYCODE_F5                     = 63;
    const static int KEYCODE_F6                     = 64;
    const static int KEYCODE_F7                     = 65;
    const static int KEYCODE_F8                     = 66;
    const static int KEYCODE_F9                     = 67;
    const static int KEYCODE_F10                    = 68;

    const static int KEYCODE_NUMLOCK                = 69;
    const static int KEYCODE_SCROLLLOCK             = 70;

    const static int KEYCODE_KEYPAD7                = 71;
    const static int KEYCODE_CURSORUPLEFT           = 71;
    const static int KEYCODE_KEYPAD8                = 72;
    const static int KEYCODE_CURSORUP               = 72;
    const static int KEYCODE_KEYPAD9                = 73;
    const static int KEYCODE_CURSORUPRIGHT          = 73;
    const static int KEYCODE_KEYPADMINUS            = 74;
    const static int KEYCODE_KEYPAD4                = 75;
    const static int KEYCODE_CURSORLEFT             = 75;
    const static int KEYCODE_KEYPAD5                = 76;
    const static int KEYCODE_KEYPAD6                = 77;
    const static int KEYCODE_CURSORRIGHT            = 77;
    const static int KEYCODE_KEYPADPLUS             = 78;
    const static int KEYCODE_KEYPAD1                = 79;
    const static int KEYCODE_CURSORDOWNLEFT         = 79;
    const static int KEYCODE_KEYPAD2                = 80;
    const static int KEYCODE_CURSORDOWN             = 80;
    const static int KEYCODE_KEYPAD3                = 81;
    const static int KEYCODE_CURSORDOWNRIGHT        = 81;
    const static int KEYCODE_KEYPAD0                = 82;
    const static int KEYCODE_KEYPADPERIOD           = 83;

    const static int KEYCODE_LESS                   = 86;

    const static int KEYCODE_F11                    = 87;
    const static int KEYCODE_F12                    = 88;

    const static int KEYCODE_KEYPADENTER            = 96;
    const static int KEYCODE_RIGHTCONTROL           = 97;
    const static int KEYCODE_CONTROL                = 97;
    const static int KEYCODE_KEYPADDIVIDE           = 98;
    const static int KEYCODE_PRINTSCREEN            = 99;
    const static int KEYCODE_RIGHTALT               = 100;
    const static int KEYCODE_BREAK                  = 101;    /* Beware: is 119     */
    const static int KEYCODE_BREAK_ALTERNATIVE      = 119;    /* on some keyboards! */

    const static int KEYCODE_HOME                   = 102;
    const static int KEYCODE_CURSORBLOCKUP          = 103;    /* Cursor key block */
    const static int KEYCODE_PAGEUP                 = 104;
    const static int KEYCODE_CURSORBLOCKLEFT        = 105;    /* Cursor key block */
    const static int KEYCODE_CURSORBLOCKRIGHT       = 106;    /* Cursor key block */
    const static int KEYCODE_END                    = 107;
    const static int KEYCODE_CURSORBLOCKDOWN        = 108;    /* Cursor key block */
    const static int KEYCODE_PAGEDOWN               = 109;
    const static int KEYCODE_INSERT                 = 110;
    const static int KEYCODE_REMOVE                 = 111;

    const static int KEYCODE_PAUSE                  = 119;

    const static int KEYCODE_POWER                  = 116;
    const static int KEYCODE_POWER1                 = 120;
    const static int KEYCODE_SLEEP                  = 121;
    const static int KEYCODE_WAKEUP                 = 122;

    const static int KEYCODE_LEFTWIN                = 125;
    const static int KEYCODE_RIGHTWIN               = 126;
    const static int KEYCODE_MENU                   = 127;

    const static int KEYCODE_LEFTBUTTON             = 0x1000;
    const static int KEYCODE_RIGHTBUTTON            = 0x2000;
    const static int KEYCODE_MIDDLBUTTON            = 0x4000;
    class Callback {
        public:
            virtual bool onKeyDown(int keyCode, KeyEvent& keyEvent) = 0;
            virtual bool onKeyUp(int keyCode, KeyEvent& keyEvent) = 0;
            virtual bool onKeyLongPress(int keyCode, KeyEvent& keyEvent) = 0;
    };
    KeyEvent(){};
    KeyEvent(int action, int keyCode) : mAction(action), mKeyCode(keyCode){};
    ~KeyEvent(){};

    int getAction(){return this->mAction;};
    int getKeyCode(){return this->mKeyCode;};

   private:
    int mAction = ACTION_UP;
    int mKeyCode = KEYCODE_MIDDLBUTTON;
};

#endif /* CPP_KEYEVENT_H */